package br.com.imob.factory;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import br.com.imob.service.ImobService;

public class ImobServiceContext {

	public static final String IMOB_SERVICE = "imobService";
	
	private ApplicationContext context;
    
    private static ImobServiceContext instance;
        
    private ImobServiceContext(){
        this.context = new ClassPathXmlApplicationContext( "application-context.xml" );     
    }
    
    public static ImobServiceContext getContext(){
        if ( instance == null ){
            instance = new ImobServiceContext();
        }
        return instance;
    }
    
    public ApplicationContext getApplicationContext() {
        return context;
    }
    
    
    public ImobService getImobService(){
        return ( ImobService ) context.getBean( IMOB_SERVICE );        
    }

}
